This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com.
When you click the Knit button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:
officials$name <- paste0("[", officials$name, "](", officials$urls, ")")
photo.data <- officials %>%
mutate(ifelse(is.na(photoUrl) == FALSE, paste0(""), "Not available"))
emails.data <- officials %>%
mutate(ifelse(officials$emails == "NULL", paste("Not available"), officials$emails))
officials$photoUrl <- photo.data[, 7]
officials$emails <- emails.data[, 7]
num.to.rep <- unlist(lapply(parsed.data$offices$officialIndices, length))
expanded <- offices[rep(row.names(offices), num.to.rep), ]
officials <- officials %>% mutate(index = row_number() -1)
expanded <- expanded %>% mutate(index = row_number() -1) %>%
rename(position = name)
joined <- left_join(officials, expanded)
## Joining, by = "index"
joined <- select(joined, name, position, party, emails, phones, photoUrl)
officials <- joined
kable(officials)
| name | position | party | emails | phones | photoUrl |
|---|---|---|---|---|---|
| Donald J. Trump | President of the United States | Republican | Not available | (202) 456-1111 | |
| Mike Pence | Vice-President of the United States | Republican | Not available | (202) 456-1111 | |
| John McCain | United States Senate | Republican | Not available | (202) 224-2235 | |
| Jeff Flake | United States Senate | Republican | Not available | (202) 224-4521 | |
| Doug Ducey | Governor | Republican | engage@az.gov | (602) 542-4331 | |
| Greg Stanton | Mayor | Democrat | mayor.stanton@phoenix.gov | (602) 262-7111 | |
| Paul Penzone | Sheriff | Democratic | Not available | (602) 876-1801 | Not available |
| Paul D. Petersen | Assessor | Republican | Not available | (602) 506-3406 | Not available |
| Adrian Fontes | Recorder | Democratic | Not available | (602) 506-3535 | Not available |
| Royce T. Flora | Treasurer | Republican | Not available | (602) 506-8511 | Not available |
| Bill Montgomery | County Attorney | Republican | Not available | (602) 506-3411 | Not available |
| Michael K. Jeanes | Clerk of the Court | Nonpartisan | coccustomerrelations@mail.maricopa.gov | (602) 372-5375 | Not available |
| Steve Watson | School Superintendent | Republican | Steve.Watson@mcesa.maricopa.gov | (602) 506-3866 | Not available |
| Jeff DeWit | State Treasurer | Republican | Not available | (602) 542-7800 | Not available |
| Mark Brnovich | Attorney General | Republican | aginfo@azag.gov | (602) 542-5025 | Not available |
| Michele Reagan | Secretary of State | Republican | Not available | (602) 542-4285 | Not available |
| Joe Hart | State Mine Inspector | Republican | Not available | (602) 542-5971 | Not available |
| Tom Forese | Corporation Commissioner | Republican | Forese-web@azcc.gov | (602) 542-3933 | Not available |
| Bob Burns | Corporation Commissioner | Republican | RBurns-web@azcc.gov | (602) 542-3682 | Not available |
| Boyd Dunn | Corporation Commissioner | Republican | Not available | (602) 542-3026 | Not available |
| Vacant | Corporation Commissioner | NA | Not available | (602) 542-0745 | Not available |
| Andy Tobin | Corporation Commissioner | Republican | Not available | (602) 542-3026 | Not available |
| Diane M Douglas | Superintendent of Public Instruction | Republican | superintendent@azed.gov | (602) 542-3710 | Not available |
gender.plot <- barplot(gender.data, horiz = TRUE)
party.plot <- barplot(party.data, horiz = TRUE)
Let's learn a bit more about one representative, Tom O’Halleran. The representative is 71 years old, and you can find them on twitter at repohalleran. Interestingly, of the last 20 congressional votes, the representative was inaccordance with the majority 30% of the time.